package cn.ailanyin.home.common.utils;

import cn.ailanyin.home.module.category.entity.Category;
import cn.ailanyin.home.module.category.vo.CategoryVO;
import cn.ailanyin.home.module.cupboard.entity.Cupboard;
import cn.ailanyin.home.module.cupboard.vo.CupboardVO;
import cn.ailanyin.home.module.things.entity.Things;
import cn.ailanyin.home.module.things.vo.ThingsVO;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 小怪兽
 * @version 1.0
 * @date 2024/4/13 0013 14:23:14
 */
public class VOUtil {
    /**
     * 转型
     *
     * @param list 列表
     * @return {@link List}<{@link CategoryVO}>
     */
    public static List<CategoryVO> getCategoryVOs(List<Category> list) {
        List<CategoryVO> vos = new ArrayList<>();
        for (Category category : list) {
            vos.add(getCategoryVO(category));
        }
        return vos;
    }

    /**
     * 转型
     *
     * @param category 分类
     * @return {@link CategoryVO}
     */
    private static CategoryVO getCategoryVO(Category category) {
        CategoryVO vo = new CategoryVO();
        vo.setId(category.getId());
        vo.setName(category.getName());
        vo.setCreateTime(category.getCreateTime());
        vo.setCreateUser(category.getCreateUser());
        vo.setUpdateTime(category.getUpdateTime());
        vo.setUpdateUser(category.getUpdateUser());
        return vo;
    }

    /**
     * 转型
     *
     * @param list 列表
     * @return {@link List}<{@link CupboardVO}>
     */
    public static List<CupboardVO> getCupboardVOs(List<Cupboard> list) {
        List<CupboardVO> vos = new ArrayList<>();
        for (Cupboard cupboard : list) {
            vos.add(getCupboardVO(cupboard));
        }
        return vos;
    }

    /**
     * 转型
     *
     * @param cupboard 橱柜
     * @return {@link CupboardVO}
     */
    private static CupboardVO getCupboardVO(Cupboard cupboard) {
        CupboardVO vo = new CupboardVO();
        vo.setId(cupboard.getId());
        vo.setLocation(cupboard.getLocation());
        vo.setImgUrl(cupboard.getImgUrl());
        vo.setHomeId(cupboard.getHomeId());
        vo.setCreateUser(cupboard.getCreateUser());
        vo.setCreateTime(cupboard.getCreateTime());
        vo.setUpdateUser(cupboard.getUpdateUser());
        vo.setUpdateTime(cupboard.getUpdateTime());
        return vo;
    }

    /**
     * 转型
     *
     * @param things       事物
     * @param categoryName 分类姓名
     * @param location     位置
     * @return {@link ThingsVO}
     */
    public static ThingsVO getThingsVO(Things things, String categoryName, String location) {
        ThingsVO vo = new ThingsVO();
        vo.setId(things.getId());
        vo.setName(things.getName());
        vo.setCount(things.getCount());
        vo.setImgUrls(things.getImgUrls());
        vo.setCategoryId(things.getCategoryId());
        vo.setCategoryName(categoryName);
        vo.setCupboardId(things.getCupboardId());
        vo.setLocation(location);
        vo.setCreateUser(things.getCreateUser());
        vo.setCreateTime(things.getCreateTime());
        vo.setUpdateUser(things.getUpdateUser());
        vo.setUpdateTime(things.getUpdateTime());
        return vo;

    }
}
